﻿using Abp.Domain.Entities.Auditing;
using FwProject.Authorization.Users;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text;

namespace FwProject.ShoppingMall.Com
{
    /// <summary>
    /// 用户订单表
    /// </summary>
    [Table("shop_order")]
    public class ShopOrder: FullAuditedEntity<Guid>
    {
        public const int MaxReceivingAddressLength = 200;
        /// <summary>
        /// 用户id
        /// </summary>
        public long UserId { get; set; }

        /// <summary>
        /// 订单编号
        /// </summary>
        public string OrderNumber { get; set; }

        /// <summary>
        /// 支付宝交易号
        /// </summary>
        public string alipayTradeNo { get; set; }

        /// <summary>
        /// 支付状态
        /// </summary>
        public PayStatus PayStatus { get; set; } = PayStatus.未支付;

        /// <summary>
        /// 支付方式
        /// </summary>
        public PayType PayType { get; set; } = PayType.微信支付;

        /// <summary>
        /// 总支付金额
        /// </summary>
        public decimal PayTotal { get; set; } = 0m;

        /// <summary>
        /// 优惠金额
        /// </summary>
        public decimal PyaPreferentia { get; set; } = 0m;

        /// <summary>
        /// 应付总金额
        /// </summary>
        public decimal PayAmount { get; set; } = 0m;

        /// <summary>
        /// 收货地址
        /// </summary>
        [MaxLength(MaxReceivingAddressLength)]
        public Guid ReceivingAddress { get; set; }

        [ForeignKey("ReceivingAddress")]
        public virtual ShopReceivingAddress ShopReceivingAddress { get; set; }

        #region 收货信息
        public string ActualReceivingName { get; set; }
        public string ActualReceivingTel { get; set; }
        public string ActualReceivingAddress { get; set; }
        #endregion



        /// <summary>
        /// 付款时间
        /// </summary>
        public DateTime? PayTime { get; set; }

        /// <summary>
        /// 买家留言
        /// </summary>
        public string OrderLeavingMessage { get; set; }

        /// <summary>
        /// 订单发货状态
        /// </summary>
        public DeliveryStatus DeliveryStatus { get; set; } = DeliveryStatus.未发货;


    }
    public enum PayStatus : byte
    {
        未支付,
        已支付,
        取消订单
    }
    public enum PayType:byte
    {
        微信支付,
        支付宝支付
    }

  
}
